/*****************************************************************
myd engine v0.1

File: myd_vertexbuffer.h
Created: 26/05/09
*****************************************************************/

#ifndef MYD_VERTEX_BUFFER_H
#define MYD_VERTEX_BUFFER_H

#include <windows.h>
#include <d3d9.h>
#include <assert.h>

namespace myd
{
template<class VertexFormat, unsigned int FVF>

class Vertexbuffer
{
public:
	bool create(IDirect3DDevice9* D3Ddevice, bool bDynamic);
	void bind(void) const;
	void flush(void);
	void draw(const VertexFormat* vertices, D3DPRIMITIVETYPE ePrimitive, unsigned int uiVertexCount);
	void release();
	Vertexbuffer(void);
	~Vertexbuffer(void);

private:
	unsigned int uiVBOSize;
	unsigned int uiFlush;
	unsigned int uiBase;
	unsigned int uiVertexToLock;

	D3DPRIMITIVETYPE m_ePrimitiveType;
	IDirect3DVertexBuffer9* wn_VBO; //to renderer
	IDirect3DDevice9* wn_D3Ddevice;

	std::vector<TextureVertex> verticesVector;
};
#include "myd_vertexbuffer.inl"

}
#endif // _VS_MYD_VERTEX_BUFFER_H_